<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" layout:decorate="~{layout}">
<head>
    <script>
        $(function(){
            $("#queryBlockByNumber").click(function(){
// 处理表单验证和交给后台处理的逻辑
                var oError = document.getElementById("error_box");
                var traceId = $("#traceId").val();
                var isNotError = true;
                if(traceId==""){
                    oError.innerHTML = "区块编号名为空 ";
                    isNotError = false;
                    $("#traceId").focus();
                    return;
                }
                $.ajax({
                    type: "POST",
                    url:"/simple/trace",
                    dataType: "json",
                    contentType:"application/json",
                    data:JSON.stringify({
                        traceId: traceId,
                        orgId: "5",
                        fcn: "queryBlockByNumber"
                    }),
                    //data:dataString,
                    success:function(data){
                        var str = JSON.stringify(data.data);
                        alert(str);
                    }

                });

            });
            $("#queryFarm").click(function(){
// 处理表单验证和交给后台处理的逻辑
                var oError = document.getElementById("error_box");
                var queryFarmArgs0 = $("#queryAllArgs0").val();

                var isNotError = true;
                if(queryFarmArgs0==""){
                    oError.innerHTML = "食品编号名为空 ";
                    isNotError = false;
                    $("#traceId").focus();
                    return;
                }
                $.ajax({
                    type: "POST",
                    url:"/simple/chaincode",
                    dataType: "json",
                    contentType:"application/json",
                    data:JSON.stringify({
                        array: [queryFarmArgs0],
                        orgId: "5",
                        fcn: "queryFarm",
                        type:"query",

                    }),
                    //data:dataString,
                    success:function(data){
                        var str = JSON.stringify(data);
                        alert(str);
                    }

                });

            });
            $("#queryDistributor").click(function(){
// 处理表单验证和交给后台处理的逻辑
                var oError = document.getElementById("error_box");
                var queryDistributorArgs0 = $("#queryAllArgs0").val();

                var isNotError = true;
                if(queryDistributorArgs0==""){
                    oError.innerHTML = "食品编号名为空 ";
                    isNotError = false;
                    $("#queryDistributorArgs0").focus();
                    return;
                }
                $.ajax({
                    type: "POST",
                    url:"/simple/chaincode",
                    dataType: "json",
                    contentType:"application/json",
                    data:JSON.stringify({
                        array: [queryDistributorArgs0],
                        orgId: "5",
                        fcn: "queryDistributor",
                        type:"query",

                    }),
                    //data:dataString,
                    success:function(data){
                        var str = JSON.stringify(data.result);
                        alert(str);
                    }

                });

            });
            $("#querySupermarket").click(function(){
// 处理表单验证和交给后台处理的逻辑
                var oError = document.getElementById("error_box");
                var querySupermarketArgs0 = $("#queryAllArgs0").val();

                var isNotError = true;
                if(querySupermarketArgs0==""){
                    oError.innerHTML = "食品编号为空 ";
                    isNotError = false;
                    $("#querySupermarketArgs0").focus();
                    return;
                }
                $.ajax({
                    type: "POST",
                    url:"/simple/chaincode",
                    dataType: "json",
                    contentType:"application/json",
                    data:JSON.stringify({
                        array: [querySupermarketArgs0],
                        orgId: "5",
                        fcn: "querySupermarket",
                        type:"query",

                    }),
                    //data:dataString,
                    success:function(data){
                        var str = JSON.stringify(data.result);
                        alert(str);
                    }

                });

            });
            $("#queryRegulator").click(function(){
// 处理表单验证和交给后台处理的逻辑
                var oError = document.getElementById("error_box");
                var queryRegulatorArgs0 = $("#queryAllArgs0").val();

                var isNotError = true;
                if(queryRegulatorArgs0==""){
                    oError.innerHTML = "食品编号为空 ";
                    isNotError = false;
                    $("#queryRegulatorArgs0").focus();
                    return;
                }
                $.ajax({
                    type: "POST",
                    url:"/simple/chaincode",
                    dataType: "json",
                    contentType:"application/json",
                    data:JSON.stringify({
                        array: [queryRegulatorArgs0],
                        orgId: "5",
                        fcn: "queryRegulator",
                        type:"query",

                    }),
                    //data:dataString,
                    success:function(data){
                        var str = JSON.stringify(data.result);
                        alert(str);
                    }

                });

            });

            $("#queryAll").click(function () {
                var oError = document.getElementById("error_box");
                var queryAllArgs0 = $("#queryAllArgs0").val();

                var isNotError = true;
                if(queryAllArgs0==""){
                    oError.innerHTML = "食品编号名为空 ";
                    isNotError = false;
                    $("#traceId").focus();
                    return;
                }
                $.ajax({
                    type: "POST",
                    url:"/simple/chaincode",
                    dataType: "json",
                    contentType:"application/json",
                    data:JSON.stringify({
                        array: [queryAllArgs0],
                        orgId: "5",
                        fcn: "queryFarm",
                        type:"query",

                    }),
                    //data:dataString,
                    success:function(data){
                        $("#uidFarm").text(data.uid.toString());
                        $("#sourceFarm").text(data.source.toString());
                        $("#whereaboutsFarm").text(data.whereabouts.toString());
                        $("#productParametersFarm").text(data.productParameters.toString());
                    },
                    error:function (data) {
                        $("#uidFarm").text("");
                        $("#sourceFarm").text("");
                        $("#whereaboutsFarm").text("");
                        $("#productParametersFarm").text("");
                    }

                });
                $.ajax({
                    type: "POST",
                    url:"/simple/chaincode",
                    dataType: "json",
                    contentType:"application/json",
                    data:JSON.stringify({
                        array: [queryAllArgs0],
                        orgId: "5",
                        fcn: "queryDistributor",
                        type:"query",

                    }),
                    //data:dataString,
                    success:function(data){
                        $("#uidDistributor").text(data.uid.toString());
                        $("#sourceDistributor").text(data.source.toString());
                        $("#whereaboutsDistributor").text(data.whereabouts.toString());
                        $("#productParametersDistributor").text(data.productParameters.toString());
                    },
                    error:function (data) {
                        $("#uidDistributor").text("");
                        $("#sourceDistributor").text("");
                        $("#whereaboutsDistributor").text("");
                        $("#productParametersDistributor").text("");
                    }


                });
                $.ajax({
                    type: "POST",
                    url:"/simple/chaincode",
                    dataType: "json",
                    contentType:"application/json",
                    data:JSON.stringify({
                        array: [queryAllArgs0],
                        orgId: "5",
                        fcn: "querySupermarket",
                        type:"query",

                    }),
                    //data:dataString,
                    success:function(data){
                        $("#uidSupermarket").text(data.uid.toString());
                        $("#sourceSupermarket").text(data.source.toString());
                        $("#whereaboutsSupermarket").text(data.whereabouts.toString());
                        $("#productParametersSupermarket").text(data.productParameters.toString());
                    },
                    error:function (data) {
                        $("#uidSupermarket").text("");
                        $("#sourceSupermarket").text("");
                        $("#whereaboutsSupermarket").text("");
                        $("#productParametersSupermarket").text("");
                    }

                });
                $.ajax({
                    type: "POST",
                    url:"/simple/chaincode",
                    dataType: "json",
                    contentType:"application/json",
                    data:JSON.stringify({
                        array: [queryAllArgs0],
                        orgId: "5",
                        fcn: "queryRegulator",
                        type:"query",

                    }),
                    //data:dataString,
                    success:function(data){
                        $("#uidRegulator").text(data.uid.toString());
                        $("#sourceRegulator").text(data.source.toString());
                        $("#whereaboutsRegulator").text(data.whereabouts.toString());
                        $("#productParametersRegulator").text(data.productParameters.toString());
                    },
                    error:function (data) {
                        $("#uidRegulator").text("");
                        $("#sourceRegulator").text("");
                        $("#whereaboutsRegulator").text("");
                        $("#productParametersRegulator").text("");
                    }

                });
            })
        });
    </script>
    <style>
        *{
            margin:0;
            padding:0;
            font-family: Arial,helvetica,"Microsoft Yahei",sans-serif;;
            font-size:16px;
        }
        body{
            overflow: hidden;//隐藏滚动条
        }
        h1 {
            color: #fff;
            font-size: 35px;
            font-weight: bold;
            margin: 80px auto 50px -25px;
            text-align: center;
            text-shadow: 0 1px 1px #555;
        }
        .box{
            width:390px;
            height:320px;

            border:solid 1px #ddd;
            border-radius:5px;
            background:#FFF;
            position:absolute;
            left:50%;
            top:50%;
            margin-left:-195px;
            margin-top:-160px;/*注意处理浏览器圆角的兼容  */
            -webkit-box-shadow: 1px 1px 2px 0 rgba(0, 0, 0, .3);
            box-shadow: 1px 1px 2px 0 rgba(0, 0, 0, .3);
        }
        .box h2{
            font-weight:normal;
            color:#666;
            font-size:16px;
            line-height:46px;
            height:46px;
            overflow:hidden;
            text-align:center;
            border-bottom:solid 1px #ddd;
            background:#f7f7f7;
        }
        .input_box{
            width:350px;
            padding-bottom:15px;
            margin:0 auto;
            overflow:hidden;
        }
        .input_box input{
            float:left;
            width:348px;
            height:40px;
            font-size:14px;
            border:solid 1px #ddd;
            border-radius:5px;
            text-indent:10px;
            outline:none;
            line-height:40px;
        }
        .input_box button{
            width:350px;
            height:48px;
            background:#008386;
            border:none;
            border-radius:5px;
            outline:none;
            cursor:pointer;
            font-size:16px;
            color:#FFF;
        }
        #error_box{
            height:40px;
            width:350px;
            margin:0 auto;
            line-height:40px;
            color:#fc4343;
        }
    </style>
</head>
<body>
<div layout:fragment="content" th:remove="tag">
    <button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal1">
        queryBlockByNumber
    </button>
    <div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"
                            aria-hidden="true">×
                    </button>
                    <h4 class="modal-title" id="myModalLabel1">
                        queryBlockByNumber
                    </h4>
                </div>
                <div class="modal-body">
                    <div class="input_box">
                        <input type="text" placeholder="请输入区块编号" id="traceId" name="tracedId"/>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default"
                            data-dismiss="modal">关闭
                    </button>
                    <button type="button" class="btn btn-primary" id="queryBlockByNumber">
                        查询
                    </button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div>
    <button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal2">
        queryAll
    </button>
    <div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"
                            aria-hidden="true">×
                    </button>
                    <h4 class="modal-title" id="myModalLabel2">
                        <div class="input_box">
                            <input type="text" placeholder="请输入食品编号" id="queryAllArgs0" name="queryAllId"/>
                            <button type="button" class="btn btn-primary" id="queryAll">
                                查询
                            </button>
                        </div>
                    </h4>
                </div>
                <div class="modal-body">
                    <table border="1">
                        <tr>
                            <th>uid</th>
                            <th>type</th>
                            <th>source</th>
                            <th>whereabouts</th>
                            <th>productParameters</th>
                        </tr>
                        <tr>
                            <td><div id="uidFarm"></div></td>
                            <td>Farm</td>
                            <td><div id="sourceFarm"></div></td>
                            <td><div id="whereaboutsFarm"></div></td>
                            <td><div id="productParametersFarm"></div></td>
                        </tr>
                        <tr>
                            <td><div id="uidDistributor"></div></td>
                            <td>Distributor</td>
                            <td><div id="sourceDistributor"></div></td>
                            <td><div id="whereaboutsDistributor"></div></td>
                            <td><div id="productParametersDistributor"></div></td>
                        </tr>
                        <tr>
                            <td><div id="uidSupermarket"></div></td>
                            <td>Supermarket</td>
                            <td><div id="sourcebalance1Supermarket"></div></td>
                            <td><div id="whereaboutsbalance1Supermarket"></div></td>
                            <td><div id="productParametersSupermarket"></div></td>
                        </tr>
                        <tr>
                            <td><div id="uidRegulator"></div></td>
                            <td>Regulator</td>
                            <td><div id="sourceRegulator"></div></td>
                            <td><div id="whereaboutsRegulator"></div></td>
                            <td><div id="productParametersRegulator"></div></td>
                        </tr>
                    </table>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default"
                            data-dismiss="modal">关闭
                    </button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div>



</div>

</body>
</html>